﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace QandA
{
    public partial class TestsForm : Form
    {
        public TestsForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// The list of tests displayed in the list box
        /// </summary>
        public QuestionBankDefinedTests TestsList
        {
            get
            {
                QuestionBankDefinedTests r = new QuestionBankDefinedTests();
                if (TestsListBox.Items.Count != 0)
                {
                    r.Tests = new QuestionBankTestDefinition[TestsListBox.Items.Count];
                }
                else
                {
                    r.Tests = null;
                }

                return r;
            }
            set
            {
                TestsListBox.Items.Clear();
                foreach (QuestionBankTestDefinition def in value.Tests)
                {
                    TestsListBox.Items.Add(def);
                }
                TestsListBox.SelectedIndex = 0;
            }
        }

        /// <summary>
        /// The test selected to be taken by the user.
        /// </summary>
        public QuestionBankTestDefinition SelectedTest
        {
            get
            {
                return (QuestionBankTestDefinition)TestsListBox.SelectedItem;
            }
        }
    }
}
